package com.app.zenmewan.service.impl;

import com.app.zenmewan.entity.UserStatstic;
import com.app.zenmewan.dao.UserStatsticDao;
import com.app.zenmewan.service.UserStatsticService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (UserStatstic)表服务实现类
 *
 * @author makejava
 * @since 2020-05-08 16:46:48
 */
@Service("userStatsticService")
public class UserStatsticServiceImpl implements UserStatsticService {
    @Resource
    private UserStatsticDao userStatsticDao;

    /**
     * 通过ID查询单条数据
     *
     * @param uid 主键
     * @return 实例对象
     */
    @Override
    public UserStatstic queryById(Integer uid) {
        return this.userStatsticDao.queryById(uid);
    }

    @Override
    public List<UserStatstic> queryAll(UserStatstic userStatstic) {
        return this.userStatsticDao.queryAll(userStatstic);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit 查询条数
     * @return 对象列表
     */
    @Override
    public List<UserStatstic> queryAllByLimit(int offset, int limit) {
        return this.userStatsticDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param userStatstic 实例对象
     * @return 实例对象
     */
    @Override
    public UserStatstic insert(UserStatstic userStatstic) {
        this.userStatsticDao.insert(userStatstic);
        return userStatstic;
    }

    /**
     * 修改数据
     *
     * @param userStatstic 实例对象
     * @return 实例对象
     */
    @Override
    public UserStatstic update(UserStatstic userStatstic) {
        this.userStatsticDao.update(userStatstic);
        return this.queryById(userStatstic.getUid());
    }

    /**
     * 通过主键删除数据
     *
     * @param uid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Integer uid) {
        return this.userStatsticDao.deleteById(uid) > 0;
    }
}